<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>{{if .shop}}{{.shop.name}} {{else}}{{$.system.name}} {{end}}</title>
    <meta charset="utf-8" name="keywords" content="{{.system.keywords}}" />
    <meta charset="utf-8" name="description" content="{{.system.description}}" />
    <link rel ="shortcut Icon" href="{{.system.pathname}}">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/css/index.min.css" />
    <link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/font/iconfont.css">
    <link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/css/pc/pcbase.css">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/css/xcConfirm.css">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/css/toast.css" />
    <style type="text/css">
     .logo{width: 60px !important}
     .store dl{position: relative;}
     .store dl .x{position: absolute;width: 50px;height: 50px;top: 3px;left: 15px}
    </style>
  </head>
  
  <body style="overflow-x: auto!important;" class="search">
    <!--from fragment-->
    {{template "pc/public/head.html" .}}
   <div class="storeHeader">
      <div>
        {{if .shop}}
        <div class="logo"><img src="{{.shop.pathname}}"></div>
        <div class="storeInfo">
          <dl>
            <a href="/shop?id={{.shop.id}}"><dt>{{.shop.name}}</dt></a>
            <!-- <dd><label>品牌直销</label></dd> -->
          </dl>
        {{else}}
        <div class="logo"><img src="{{$.system.pathname}}"></div>
        <div class="storeInfo">
          <dl>
            <a href="/shop?id=0"><dt>{{$.system.name}}</dt></a>
            <dd><label>官方自营</label></dd>
          </dl>
        {{end}}
          <div class="score">
            <dl>
              <dt>服务</dt>
              <dd>{{.score.avgscore}}<!-- <i class="iconfont">&#xe818;</i> --></dd>
            </dl>
            <dl>
              <dt>物流</dt>
              <dd>{{.score.logisticsscore}}<!-- <i class="iconfont">&#xe819;</i> --></dd>
            </dl>
          </div>
        </div>
        <div class="storeSearch">
          <form action="/shop">
            <input type="text" name="search" placeholder="搜索 产品">
            <input type="hidden" name="id" value="{{.gid}}">
            <button>搜本店</button>
          </form>
        </div>
      </div>
    </div>
    <div class="storeHd">
      <div>
        <div class="storeHdImg" style="background-image: url({{if .shop.bpath}}{{.shop.bpath}}{{else}}{{.shop.webpath}}{{end}});"></div>
        <ul>
          <!-- <li><a href="">首页</a></li> -->
          <li><a href="/shop?id={{$.gid}}">首页</a></li>
          <li><a href="/shop_sales?id={{$.gid}}">限时促销</a></li>
          {{range .column}}
          <li><a href="/shop?id={{$.gid}}&cid={{.id}}">{{.name}}</a></li>
          {{end}}
        </ul>
      </div>
    </div>
    <div class="store">
      {{if eq .cid ""}}
      {{if eq .search ""}}
      {{if .news}}
      <div class="newprd">
        <div class="Hd">
          <p>精选新品</p>
          <p>New Arrivals</p>
        </div>
        {{range .news}}
        <a href="/product/content?id={{.id}}">
        <dl>
          <dt style="background-image: url({{.pathname}});"></dt>
          <dd>
            <p>{{.title}}</p>
            {{if .vprice}}
            <p>
              <span>总销量:{{.sellnum}}</span><span>价格 <s>&yen; {{.price}}</s></span>
            </p>
            <p>RMB {{.vprice}}</p>
            {{else}}
            <p>
              <span>总销量:{{.sellnum}}</span>
            </p>
            <p>RMB {{.price}}</p>
            {{end}}
            <a href="/product/content?id={{.id}}">
            <button>立即购买</button>
            </a>
          </dd>
           {{if eq .active 1}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/gbuy.png" class="x">
          {{else if eq .active 2}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/sales.png" class="x">
          {{end}}
        </dl>
        </a>
        {{end}}
      </div>
      {{end}}
      {{if .rec}}
      <div class="rcmdprd">
        <div class="Hd">
          <p>店铺推荐</p>
          <p>Recommendation</p>
        </div>
        {{range .rec}}
        <a href="/product/content?id={{.id}}">
        <dl>
          <dt style="background-image: url({{.pathname}});"></dt>
          <dd>
            <p>{{.title}}</p>
            {{if .vprice}}
            <p>
              <span>总销量:{{.sellnum}}</span><span>价格 <s>&yen; {{.price}}</s></span>
            </p>
            <p>RMB {{.vprice}}</p>
            {{else}}
            <p>
              <span>总销量:{{.sellnum}}</span>
            </p>
            <p>RMB {{.price}}</p>
            {{end}}
            <a href="/product/content?id={{.id}}">
            <button>立即购买</button>
            </a>
          </dd>
           {{if eq .active 1}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/gbuy.png" class="x">
          {{else if eq .active 2}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/sales.png" class="x">
          {{end}}
        </dl>
        </a>
        {{end}}
      </div>
      {{end}}
      {{end}}
      {{end}}
      {{if eq .cid ""}}
      {{if eq .search ""}}
      {{if .coupon}}
      <div class="coupon">
        <div class="Hd">
          <p>店铺卡券</p>
          <p>Shop coupons</p>
        </div>
        <div class="cpl">
          {{range .coupon}}
          <div>
            <dl>
              <dt><span>&yen;</span>{{.offer}}</dt>
              <dd>
                <p>优惠券</p>
                <p>满{{.full}}使用</p>
              </dd>
            </dl>
            {{if eq .isget 1}}
            <button disabled>已领取</button>
            {{else}}
            <button class="get" data-id="{{.id}}">领取</button>
            {{end}}
          </div>
          {{end}}
        </div>
      </div>
      {{end}}
      {{end}}
      {{end}}
      <div class="moreprd">
        {{if eq .cid ""}}
        {{if eq .search ""}}
        <div class="Hd">
          <p>更多产品</p>
          <p>More products</p>
        </div>
        {{end}}
        {{end}}
        {{range .info}}
        <a href="/product/content?id={{.id}}">
        <dl>
          <dt style="background-image: url({{.pathname}});"></dt>
          <dd>
            <p>{{.title}}</p>
            {{if .vprice}}
            <p>
              <span>总销量:{{.sellnum}}</span><span>价格 <s>&yen; {{.price}}</s></span>
            </p>
            <p>RMB {{.vprice}}</p>
            {{else}}
            <p>
              <span>总销量:{{.sellnum}}</span>
            </p>
            <p>RMB {{.price}}</p>
            {{end}}
            <a href="/product/content?id={{.id}}">
            <button>立即购买</button>
            </a>
          </dd>
          {{if eq .active 1}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/gbuy.png" class="x">
          {{else if eq .active 2}}
          <img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/sales.png" class="x">
          {{end}}
        </dl>
        </a>
        {{end}}
      </div>
      {{if .paginator}}
      {{if ne .paginator.totalpages 1}}
      <div class="pageView">
        <b class="btn">
          {{if ne .paginator.currpage 1}}
          <a href="{{$.url}}page={{.paginator.prevpage}}"><b>&lt;&lt;上一页</b></a>
          {{else}}
          <b>&lt;&lt;上一页</b>
          {{end}}
          {{range $index,$page := .paginator.pages}}
          {{if eq $.paginator.currpage $page}} 
          <b>{{$page}}</b>
          {{else}}
          <a href="{{$.url}}page={{$page}}"><b>{{$page}}</b></a>
          {{end}}
          {{end}}
          <!-- <b class="more">...</b> -->
          {{if eq .paginator.currpage .paginator.totalpages}}
          <b>下一页&gt;&gt;</b>
          {{else}}
          <a href="{{$.url}}page={{.paginator.nextpage}}"><b>下一页&gt;&gt;</b></a>
          {{end}}
        </b>
        <b class="other">
          共{{.paginator.totalpages}}页，到第<input type="text" name="p">页<button id="go">确定</button>
        </b>
      </div>
      {{else}}
      <div class="pageView">
        <b class="btn">
        <a>1</a>
      </b>
      </div>
      {{end}}
      {{end}}
    </div>
</div>
    {{template "pc/public/foot.html" .}}
  </body>
  <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/js/jquery.min.js"></script>
  <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
  <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/js/toast.js"></script>
  <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/frame/sui/js/SUI.js"></script>
  <script type="text/javascript"></script>
  <script type="text/javascript">
     $('#go').click(function(){
    var totalpages={{.paginator.totalpages}};
    var num=$('input[name="p"]').val()
    if(num<=totalpages){
      window.location.href={{.url}}+`page=`+num
    }
  })
    $('.get').click(function(){
      var id=$(this).attr('data-id')
      var that=$(this)
      $.ajax({
        url:'/product/getcoupon',
        data:{yid:id},
        success:function(res){
          if(res==2){
            wxc.xcConfirm("您还没有登入,请先登入","confirm",{onOk:function(){
            window.location.href="/login"
          }})
          }else if(res==1){
            showToast("领取成功~")
            that.html(已领取)
            that.css('color','#999')
            that.css('cursor','default')
            that.attr('class','')
          }else if(res==0){
            showToast("网络繁忙,请稍后再试!")
          }else if(res==3){
            that.html(已领取)
            that.css('color','#999')
            that.css('cursor','default')
            that.attr('class','')
          }
        }
      })
    })
  </script>
</html>